{{include file="default/Public/header.html"}}
<div id="pageTop">
	<div class="tabs"> 
		<ul>
			<li><a href='{{U url="fvote/manage?catid=`$cat.catid`"}}'>管理投票</a></li>
			<li><a href='{{U url="fvote/add?catid=`$cat.catid`"}}'>添加投票</a></li>
			<li><a href='javascript:void(0);' class="selected" rel="tabsContent1">编辑投票</a></li>
		</ul>		
	</div>
</div>
<form name="myform" class="validate" method="post" action="{{U url='fvote/edit?dosubmit=1'}}" >
<div id="pageCo">
	<div class="manageForm">
		<table cellpadding="0" cellspacing="0" class="tabcontent" id="tabsContent1">
			<tbody>
				<tr>
					<th width="15%">投票主题</th>
					<td><input name="info[subject]" size="50" maxlength="100" class="required input" title="投票主题不能为空" value="{{$data.subject}}"></td>
				</tr>
				<tr>
					<th>选项类型</th>
					<td><input type="radio" name="info[ischeckbox]" value="0" {{if $data.ischeckbox == 0}}checked{{/if}} />单选&nbsp;
				        <input type="radio" name="info[ischeckbox]" value="1" {{if $data.ischeckbox == 1}}checked{{/if}} />
				        多选&nbsp;&nbsp;&nbsp;&nbsp;
				        <span id="range_1" {{if $data.ischeckbox == 0}}style="display:none"{{/if}}>
				        最少选择<input type="text" name="info[minval]"  value="{{$data.minval}}" size="3" />项 &nbsp;&nbsp;
				        最多选择<input type="text" name="info[maxval]"  value="{{$data.maxval}}" size="3" />项
				        </span></td>
				</tr>
				<tr>
					<th>投票选项<span>提示:图片也可以直接填写远程图片地址</span></th>
					<td><input type="button" value="添加选项" id="addItem1" />
       					<div id="option_list_1">
       					{{foreach from=$data.option key=num item=option}}
       						<p>
       							<input type="hidden" name="info[option_ids][]" value="{{$option.optionid}}" />
       							<span>{{$num+1}}</span>、<input type="text" name="info[option][]" size="40" class="required input" msg="必填" id="opt{{$num+1}}" value="{{$option.option}}" />
       							图片:<input type="text" name="info[image][]" id="pic{{$num+1}}" value="{{$option.image}}" size="18" /><input type="button" value="上传图片" id="upload_img_{{$num+1}}" class="dialog" title="从电脑上传图片" alt="__ROOT__/admin.php?m=fupload&a=commonUpload&opener_id=pic{{$num+1}}&height=300&width=450">
       							&nbsp;&nbsp;<a href="javascript:void(0);" onclick="descItem(this);">删除</a>
       						</p>
       					{{/foreach}}
       					</div>
       				</td>
				</tr>
				<tr>
					<th>投票介绍</th>
					<td>{{$editer_html}}</td>
				</tr>
				<tr>
					<th>未投票人是否可以查看投票结果</th>
					<td><input type="radio" name="info[allowview]" value="1" {{if $data.allowview == 1}}checked{{/if}} />是&nbsp;&nbsp;
        				<input type="radio" name="info[allowview]" value="0" {{if $data.allowview == 0}}checked{{/if}} />否</td>
				</tr>
				<tr>
					<th>启用验证码</th>
					<td><input type="radio" name="info[enablecheckcode]" value="1" {{if $data.enablecheckcode == 1}}checked{{/if}} />是&nbsp;&nbsp;
       					<input type="radio" name="info[enablecheckcode]" value="0" {{if $data.enablecheckcode == 0}}checked{{/if}} />否</td>
				</tr>
				<tr>
					<th>投票有效期范围</th>
					<td><script language="javascript" src="__ROOT__/admin/public/js/calendar/WdatePicker.js"></script>
					<input id="d4311" name="info[fromdate]" class="Wdate required input" type="text" value="{{$data.fromdate}}" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'2020-10-01\'}'})" title="【结束时间】必填" /> 
		            &nbsp;到&nbsp;
		            <input id="d4312" name="info[todate]" class="Wdate required input" type="text" value="{{$data.todate}}" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'2020-10-01'})" title="【结束时间】必填" />
		            </td>
				</tr>
				<tr>
					<th>允许游客投票</th>
					<td><input name="info[allowguest]" type="radio" value="1" {{if $data.allowguest == 1}}checked{{/if}} />是&nbsp;&nbsp;
     					<input name="info[allowguest]" type="radio" value="0" {{if $data.allowguest == 0}}checked{{/if}} />否</td>
				</tr>
				<tr>
					<th>允许参与投票的会员角色</th>
					<td>
					{{foreach from=$role_data key=role_name item=role_nickname}}
					<input type="checkbox" name="info[groupidsvote][]" value="{{$role_name}}" {{if $role_name|in_array:$data.groupidsvote}}checked{{/if}} />{{$role_nickname}}
					{{/foreach}}
					</td>
				</tr>
				<tr>
					<th>允许查看投票结果的会员角色</th>
					<td>{{foreach from=$role_data key=role_name item=role_nickname}}
					<input type="checkbox" name="info[groupidsview][]" value="{{$role_name}}" {{if $role_name|in_array:$data.groupidsview}}checked{{/if}} />{{$role_nickname}}
					{{/foreach}}</td>
				</tr>
				<tr>
					<th>投票时间间隔(秒)<span>N秒后可再次投票，0表示此IP地址只能投一次</span></th>
					<td><input type="text" name="info[interval]" class="input" value="{{$data.interval}}" size="8" />秒</td>
				</tr>
				<tr>
					<th>启用</th>
					<td><input name="info[status]" type="radio" value="1" {{if $data.status == 1}}checked{{/if}} />是&nbsp;&nbsp;
        				<input type="radio" name="info[status]" value="0" {{if $data.status == 0}}checked{{/if}} />否</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<th>&nbsp;</th>
		            <td>
		            <input type="hidden" name="subjectid" value="{{$data.subjectid}}" />
		            <input type="hidden" name="catid" value="{{$cat.catid}}" />
		            <input type="hidden" name="forward" value='{{U url="fvote/manage?catid=`$cat.catid`"}}' />
		            <label class="btn"><input type="submit" name="submit" value="确 定" class="submit" /></label>
		            <label class="btn"><input type="reset" name="reset" value="重 置" class="submit" /></label>
		            </td>
				</tr>
			</tfoot>
		</table>
	</div>
</div>
</form>
<script type="text/javascript">
var option_num = parseInt(1+{{$data.option|@count}});
	$(function(){
		$('input[name="info[ischeckbox]"]').change(function(){
			if(this.value==1) {
				$('#range_1').show();
			} else $('#range_1').hide();
		});
		
		//添加选项
		$('#addItem1').click(function(){
			var d_obj = $('#option_list_1');
			var p_len = d_obj.children('p').length;
			d_obj.append('<p><span>'+parseInt(p_len+1)+'</span>、<input type="text" name="info[option][]" size="40" class="required input" msg="必填" id="opt'+option_num+'" /> 图片:<input type="text" name="info[image][]" id="pic'+option_num+'" size="18" /><input type="button" value="上传图片" id="upload_img_'+option_num+'" class="dialog" title="从电脑上传图片" alt="__ROOT__/admin.php?m=fupload&a=commonUpload&opener_id=pic'+option_num+'&height=300&width=450"> &nbsp;&nbsp;<a href="javascript:void(0);" onclick="descItem(this);">删除</a></p>');
			
			window.parent.mainCo && window.parent.mainCo();
			$('#opt'+option_num).focus().blur();
			option_num++;
		});
	});
function descItem(obj)
{
	$(obj).parent().remove();
	window.parent.mainCo && window.parent.mainCo();
	$('#opt'+option_num).focus().blur();
}
</script>
{{include file="default/Public/footer.html"}}